#ifndef LAYOUT_H
#define LAYOUT_H

#include <vector>
#include <functional>

#include "implementation.h"

template <typename Range>
int2 select_corner(const Range& rng, int2 direction) noexcept;

template <typename ForwardItr>
constexpr void layout_bounds(ForwardItr begin, ForwardItr end, const int2& spacing);

template <typename Range>
constexpr void layout_bounds(Range range, const int2& spacing)
{
	using std::begin;
	using std::end;
	layout_bounds(begin(range), end(range), spacing);
}


template <typename Range>
class bounds_layout : public movable_bounds
{
	public:

	bounds_layout(Range elements, int2 spacing = int2::zero());

	bounds_layout(int2 spacing);

	bounds_layout& operator+=(const int2&) override;

	range2D update();

	private:
	Range elements;
	int2 spacing;
};

template <typename R> bounds_layout(R) -> bounds_layout<R>;
template <typename R> bounds_layout(R, int2) -> bounds_layout<R>;

using bounds_layout_vector = bounds_layout<std::vector<i_movable_bounds<int2>*>>;

#endif /* end of include guard */


